package vn.allmobile.ambnews;

import android.content.Intent;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.google.analytics.tracking.android.EasyTracker;
import vn.allmobile.ambnews.R;
import vn.allmobile.ambnews.activities.main.MainAllPapersActivity;
import vn.allmobile.ambnews.utils.PreferenceManager;
public class BaseActivity extends SherlockActivity {
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if(PreferenceManager.isNightMode())
			setTheme(R.style.MbsTheme_Dark);
		else
			setTheme(R.style.MbsTheme_Light);
			
	}
	
	/* (non-Javadoc)
	 * @see com.actionbarsherlock.app.SherlockActivity#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)
	 */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getSupportMenuInflater().inflate(R.menu.main,  menu);
		return super.onCreateOptionsMenu(menu);
		
	}

	
	
	/* (non-Javadoc)
	 * @see com.actionbarsherlock.app.SherlockActivity#onMenuItemSelected(int, com.actionbarsherlock.view.MenuItem)
	 */
	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
			case R.id.menu_settings:
			 Intent mIntent_setting = new Intent(getApplicationContext(), SettingsActivity.class);			
			 startActivity(mIntent_setting);
			return true;
			case R.id.menu_tools:
				Intent mIntent_tools = new Intent(getApplicationContext(), ToolsActivity.class);			
				startActivity(mIntent_tools);
			return true;
			case R.id.menu_paper_manage:
				 Intent mIntent = new Intent(getApplicationContext(), MainAllPapersActivity.class);			
				 startActivity(mIntent);
				return true;
			case R.id.menu_exits:
				android.os.Process.killProcess(android.os.Process.myPid());
				return true;
			case R.id.menu_about:
				 Intent intent = new Intent(getApplicationContext(), AboutActivity.class);			
				 startActivity(intent);
			default :
				return super.onMenuItemSelected(featureId, item);
		}
		
	}
	
	  /* (non-Javadoc)
	 * @see android.app.Activity#onBackPressed()
	 */
	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		super.onBackPressed();
		overridePendingTransition(R.anim.grow_from_bottom,R.anim.slide_out_right);
	}

	@Override
	   protected void onStart() {
	      super.onStart();
	      EasyTracker.getInstance().activityStart(this); 
	   }
	 
	   @Override
	   protected void onStop() {
	      super.onStop();
	      EasyTracker.getInstance().activityStop(this); 
	   }
	   
	   
}
